﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Common.Net.Utilities
{
    public static class PropertyHelper
    {
        public static string GetPropertyName<T>(Expression<Func<T>> property)
        {
            if (property.Body is MemberExpression)
            {
                var memberExpr = (MemberExpression)property.Body;
                return memberExpr.Member.Name;
            }

            throw ExceptionFactory.Argument("{0} is not recognized as property", property.Body.ToString());
        }
    }
}
